#include "h_stushow.h"
#include "ui_h_stushow.h"
#include "global.h"

h_stuShow::h_stuShow(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::h_stuShow)
{
    ui->setupUi(this);
    tableviews();
}

h_stuShow::~h_stuShow()
{
    delete ui;
}

void h_stuShow::tableviews(){
    QSqlQuery query;
    QString str=QString("select * from housemaster,hb where hid=Hou_Hid and hid='%1'").arg(global::userid);
//    qDebug()<<str;
    QString bid;
    query.exec(str);
    while(query.next()){
        bid=query.value(6).toString();
    }
//    qDebug()<<bid;
    str=QString("select sid,sname,ssex,sphone,scollege,sdept,sroomid,sbuildid from student where sbuildid='%1'").arg(bid);
//    qDebug()<<str;
    model.setQuery(str);
    ui->tableView->setModel(&model);

    model.setHeaderData(0,Qt::Horizontal,"学号");
    model.setHeaderData(1,Qt::Horizontal,"姓名");
    model.setHeaderData(2,Qt::Horizontal,"性别");
    model.setHeaderData(3,Qt::Horizontal,"电话");
    model.setHeaderData(4,Qt::Horizontal,"学院");
    model.setHeaderData(5,Qt::Horizontal,"专业");
    model.setHeaderData(6,Qt::Horizontal,"房间号");
    model.setHeaderData(7,Qt::Horizontal,"楼栋号");

}
